bitkeeper revision 1.498 (3f852b5cCUvtapSFnyCRbI57fF2ilQ)
authorkaf24@scramble.cl.cam.ac.uk <kaf24@scramble.cl.cam.ac.uk>
Thu, 9 Oct 2003 09:33:16 +0000 (09:33 +0000)
committerkaf24@scramble.cl.cam.ac.uk <kaf24@scramble.cl.cam.ac.uk>
Thu, 9 Oct 2003 09:33:16 +0000 (09:33 +0000)
kernel.c, process.c, README.CD:
  Add 'noreboot' option, and auto-detection of display adaptors.

README.CD
xen/arch/i386/process.c
xen/common/kernel.c

index 919f3a44f03d8ca8168eebee83fe6789b41f4175..cfe6790e1c4301f2534d6f8141cda39df691d59d 100644 (file)
--- a/README.CD
+++ b/README.CD
@@ -275,6 +275,10 @@ that may be able to help diagnose problems:
                   by Xen. If you specify this option then ACPI tables are
                   also ignored, and SMP support is disabled.
 
+ noreboot         Don't reboot the machine automatically on errors.
+                  This is useful to catch debug output if you aren't
+                  catching console messages via the serial line.
+
  nosmp           Disable SMP support.
                   This option is implied by 'ignorebiostables'.
 
index 49f45688c6ac3688f992cb435a5de9954f9b7ded..0adcbbf47d94b8baad9590c865f6fec3e97b9f27 100644 (file)
@@ -112,9 +112,18 @@ static inline void kb_wait(void)
 
 void machine_restart(char * __unused)
 {
+    extern int opt_noreboot;
 #if CONFIG_SMP
     int cpuid;
+#endif
        
+    if ( opt_noreboot )
+    {
+        printk("Reboot disabled on cmdline: require manual reset\n");
+        for ( ; ; ) __asm__ __volatile__ ("hlt");
+    }
+
+#ifdef CONFIG_SMP
     cpuid = GET_APIC_ID(apic_read(APIC_ID));
 
     if (reboot_smp) {
index 770e21e248e0d22c8c266656b2ac1b13c986b22b..a410fd1155652d61a4c5ea4b242f16e5b7346dc2 100644 (file)
@@ -62,6 +62,8 @@ int opt_noht=0;
 int opt_noacpi=0;
 /* opt_nosmp: If true, secondary processors are ignored. */
 int opt_nosmp=0;
+/* opt_noreboot: If true, machine will need manual reset on error. */
+int opt_noreboot=0;
 /* opt_ignorebiostables: If true, ACPI and MP tables are ignored. */
 /* NB. This flag implies 'nosmp' and 'noacpi'. */
 int opt_ignorebiostables=0;
@@ -80,6 +82,7 @@ static struct {
     { "noht",             OPT_BOOL, &opt_noht },
     { "noacpi",           OPT_BOOL, &opt_noacpi },
     { "nosmp",            OPT_BOOL, &opt_nosmp },
+    { "noreboot",         OPT_BOOL, &opt_noreboot },
     { "ignorebiostables", OPT_BOOL, &opt_ignorebiostables },
     { "watchdog",         OPT_BOOL, &opt_watchdog },
     { NULL,               0,        NULL     }
@@ -284,6 +287,44 @@ void putchar_serial(unsigned char c) {}
 #define ATTRIBUTE    7
 #define VIDEO      __va(0xB8000)
 
+int detect_video(void *video_base)
+{
+    volatile u16 *p = (volatile u16 *)video_base;
+    u16 saved1 = p[0], saved2 = p[1];
+    int video_found = 1;
+
+    p[0] = 0xAA55;
+    p[1] = 0x55AA;
+    if ( (p[0] != 0xAA55) || (p[1] != 0x55AA) )
+        video_found = 0;
+
+    p[0] = 0x55AA;
+    p[1] = 0xAA55;
+    if ( (p[0] != 0x55AA) || (p[1] != 0xAA55) )
+        video_found = 0;
+
+    p[0] = saved1;
+    p[1] = saved2;
+
+    return video_found;
+}
+
+int detect_vga(void)
+{
+    /*
+     * Look at a number of well-known locations. Even if video is not at
+     * 0xB8000 right now, it will appear there when we set up text mode 3.
+     * 
+     * We assume if there is any sign of a video adaptor then it is at least
+     * VGA-compatible (surely noone runs CGA, EGA, .... these days?).
+     * 
+     * These checks are basically to detect headless server boxes.
+     */
+    return (detect_video(__va(0xA0000)) || 
+            detect_video(__va(0xB0000)) || 
+            detect_video(__va(0xB8000)));
+}
+
 /* This is actually code from vgaHWRestore in an old version of XFree86 :-) */
 void init_vga(void)
 {
@@ -308,6 +349,13 @@ void init_vga(void)
     if ( !opt_console )
         return;
 
+    if ( !detect_vga() )
+    {
+        printk("No VGA adaptor detected!\n");
+        opt_console = 0;
+        return;
+    }
+
     tmp = inb(0x3da);
     outb(0x00, 0x3c0);